package fr.expdev.bndd.widget;

import com.cyrilmottier.android.greendroid.R;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import greendroid.widget.item.Item;
import greendroid.widget.itemview.ItemView;

public class PostItemView extends RelativeLayout implements ItemView {
	
	private TextView titleTextView;
	private ImageView typeImageView;
	private ImageView favoriteImageView;

	public PostItemView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public PostItemView(Context context) {
		super(context);
	}

	@Override
	public void prepareItemView() {
        titleTextView = (TextView) findViewById(R.id.bndd_text);
        typeImageView = (ImageView) findViewById(R.id.bndd_thumbnail);
        favoriteImageView = (ImageView) findViewById(R.id.bndd_favorite);
	}

	@Override
	public void setObject(Item object) {
        final PostItem item = (PostItem)object;
        titleTextView.setText(item.text);
        typeImageView.setImageResource(item.getTypeResource());
        favoriteImageView.setImageResource(item.getFavoriteResource());
        favoriteImageView.setOnClickListener(item.getFavoriteListener());
	}

}
